package com.ruoyi.cmemetal.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.cmemetal.mapper.ZxPrintProcessMapper;
import com.ruoyi.cmemetal.domain.ZxPrintProcess;
import com.ruoyi.cmemetal.service.IZxPrintProcessService;

/**
 * PrintProcessService业务层处理
 *
 * @author zhangxu
 * @date 2021-12-30
 */
@Service
public class ZxPrintProcessServiceImpl implements IZxPrintProcessService
{
    @Autowired
    private ZxPrintProcessMapper zxPrintProcessMapper;

    /**
     * 查询PrintProcess
     *
     * @param id PrintProcess主键
     * @return PrintProcess
     */
    @Override
    public ZxPrintProcess selectZxPrintProcessById(Long id)
    {
        return zxPrintProcessMapper.selectZxPrintProcessById(id);
    }

    /**
     * 查询PrintProcess列表
     *
     * @param zxPrintProcess PrintProcess
     * @return PrintProcess
     */
    @Override
    public List<ZxPrintProcess> selectZxPrintProcessList(ZxPrintProcess zxPrintProcess)
    {
        return zxPrintProcessMapper.selectZxPrintProcessList(zxPrintProcess);
    }

    /**
     * 新增PrintProcess
     *
     * @param zxPrintProcess PrintProcess
     * @return 结果
     */
    @Override
    public int insertZxPrintProcess(ZxPrintProcess zxPrintProcess)
    {
        return zxPrintProcessMapper.insertZxPrintProcess(zxPrintProcess);
    }

    /**
     * 修改PrintProcess
     *
     * @param zxPrintProcess PrintProcess
     * @return 结果
     */
    @Override
    public int updateZxPrintProcess(ZxPrintProcess zxPrintProcess)
    {

        //修改打印处理时长
        if(zxPrintProcess.getOverTime() != null && zxPrintProcess.getStartTime() !=null){
            long time = DateUtils.zxgetDatePoor(zxPrintProcess.getOverTime(),zxPrintProcess.getStartTime());
            zxPrintProcess.setPrintrTime(time);
        }

        return zxPrintProcessMapper.updateZxPrintProcess(zxPrintProcess);
    }

    /**
     * 批量删除PrintProcess
     *
     * @param ids 需要删除的PrintProcess主键
     * @return 结果
     */
    @Override
    public int deleteZxPrintProcessByIds(Long[] ids)
    {
        return zxPrintProcessMapper.deleteZxPrintProcessByIds(ids);
    }

    /**
     * 删除PrintProcess信息
     *
     * @param id PrintProcess主键
     * @return 结果
     */
    @Override
    public int deleteZxPrintProcessById(Long id)
    {
        return zxPrintProcessMapper.deleteZxPrintProcessById(id);
    }
}
